fix(parse): use safe_extract_zip for UnderstandingAPI zip download to close Zip Slip#2634
Open
r266-tech wants to merge 1 commit into
Open
fix(parse): use safe_extract_zip for UnderstandingAPI zip download to close Zip Slip#2634r266-tech wants to merge 1 commit into
r266-tech wants to merge 1 commit into
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
UnderstandingAPI(added in #2614) extracts the third-party-downloaded result zip with a rawzipfile.ZipFile(...).extractall(), bypassing the project's canonicalsafe_extract_zipZip-Slip guard.Why
#2615's same-day hardening sweep routed every other production extractor through
safe_extract_zip(utils/zip_safe.py,utils/skill_processor.py, upload paths), but its file list didn't includeunderstanding_api.py, so this one download path still callsextractall(). A malicious or MITM'd Understanding-API result zip whose members use../../…would currently escape the temp dir and write onto the user's filesystem. Thesafe_extract_zipinvariant is deliberately source-agnostic, so even a configured-endpoint source should go through it.Change
One-line swap to the same helper
parse/parsers/zip_parser.pyalready uses:No behavior change for benign archives:
safe_extract_zipvalidates each member stays insideextract_dirand recreates the same tree the downstreamextract_path.iterdir()/ single-root-dir detection expects (safe_extract_zipPath()-coerces thestrtemp dir and callsnormalize_zip_filenamesinternally). Zip-Slip behavior is already covered centrally bytests/misc/test_zip_safe.py.